/*
 * 
 *  This file is part of Sourceprojects.org Lycia Copyright 2010 noctarius
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 * 
 */
package org.sourceprojects.lycia.internal.platform.android;

import org.sourceprojects.lycia.LyciaParser;
import org.sourceprojects.lycia.internal.platform.AttributeNameFindingStrategy;
import org.sourceprojects.lycia.internal.platform.ElementContentExtractor;
import org.sourceprojects.lycia.internal.platform.InternalXPathResolver;
import org.sourceprojects.lycia.internal.platform.ParameterMatcher;
import org.sourceprojects.lycia.internal.platform.ParameterMatcherFactory;
import org.sourceprojects.lycia.internal.platform.PlatformFactory;
import org.sourceprojects.lycia.internal.platform.PlatformSchemaFactory;
import org.sourceprojects.lycia.internal.platform.base.ElementContentExtractorImpl;
import org.sourceprojects.lycia.internal.platform.base.InternalXPathResolverImpl;
import org.sourceprojects.lycia.internal.platform.base.ParameterMatcherFactoryImpl;

public class Android2_2PlatformFactoryImpl<B> implements PlatformFactory<B> {

	private static final ParameterMatcherFactory FACTORY = new ParameterMatcherFactoryImpl();

	private final ElementContentExtractor contentExtractor = new ElementContentExtractorImpl();
	private final PlatformSchemaFactory<B> schemaFactory = new AndroidCompatibleSchemaFactoryImpl<B>();
	private final AttributeNameFindingStrategy<B> attributeNameFindingStrategy = new AndroidCompatibleAttributeNameFindingStrategyImpl<B>();

	private final InternalXPathResolver<B> xPathResolver;

	public Android2_2PlatformFactoryImpl(final LyciaParser<B> lyciaParser) {
		xPathResolver = new InternalXPathResolverImpl<B>(lyciaParser);
	}

	@Override
	public ElementContentExtractor newElementContentExtractor() {
		return contentExtractor;
	}

	@Override
	public InternalXPathResolver<B> newInternalXPathResolver() {
		return xPathResolver;
	}

	@Override
	public ParameterMatcher[] newParameterMatcher() {
		return FACTORY.provideParameterMatchers();
	}

	@Override
	public PlatformSchemaFactory<B> newPlatformSchemaFactory() {
		return schemaFactory;
	}

	@Override
	public AttributeNameFindingStrategy<B> newAttributeNameFindingStrategy() {
		return attributeNameFindingStrategy;
	}
}
